<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"><link rel="icon" href="https://jscdn.com.cn/highcharts/images/favicon.ico">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui/css/H-ui.min.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/H-ui.admin.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/lib/Hui-iconfont/1.0.8/iconfont.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/skin/default/skin.css}" id="skin" />
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/style.css}" />
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>柱状图</title>
    <script src="https://code.highcharts.com.cn/highcharts/highcharts.js"></script>
    <script src="https://code.highcharts.com.cn/highcharts/modules/exporting.js"></script>
    <script src="https://code.highcharts.com.cn/highcharts/modules/drilldown.js"></script>
    <script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 图形报表 <span class="c-gray en">&gt;</span> 柱状图 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c">
        日期范围：
        <input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}' })" id="logmin" class="input-text Wdate" style="width:120px;">
        -
        <input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d' })" id="logmax" class="input-text Wdate" style="width:120px;">
        <!--<input type="text" name="" id="" placeholder=" 资讯名称" style="width:250px" class="input-text">-->
        <button name="bt" id="bt" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </div>

    <div class="page-container">
        <div id="container" style="min-width: 280px; height: 400px; margin: 0 auto"></div>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script  th:src="@{/lib/jquery/1.9.1/jquery.min.js}"></script>
<script  th:src="@{/lib/layer/2.4/layer.js}"></script>
<script  th:src="@{/static/h-ui/js/H-ui.min.js}"></script>
<script  th:src="@{/static/h-ui.admin/js/H-ui.admin.js}"></script>  <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script th:src="@{/lib/My97DatePicker/4.8/WdatePicker.js}"></script>
<script th:src="@{/lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
<script>
    var chart = {}
    $(function () {
        $('#bt').click()
        console.log("click")

    })

    $(function () {
        chart = Highcharts.chart('container', {
                chart: {
                    type: 'column'
                },
                title: {
                    text: ''
                },
/*                subtitle: {
                    text: '点击可查看具体数据'
                },*/
                xAxis: {
                    type: 'category'
                },
                yAxis: {
                    title: {
                        text: ''
                    }
                },
                legend: {
                    enabled: false
                },
                plotOptions: {
                    series: {
                        borderWidth: 0,
                        dataLabels: {
                            enabled: true,
                        }
                    }
                },
                tooltip: {
                    headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
                    pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}</b> <br/>'
                },
                series: [{
                    name: '',
                    colorByPoint: true,
                    data: []
                }]
            }
        );
    })


    $("#bt").click(function () {
        var startTime = $('#logmin').val()
        var endTime = $('#logmax').val()
        console.log("bardata=" + startTime + endTime)
        $.ajax({
            type: 'POST',
            url: 'postBarData',
            data: {"startTime": startTime,"endTime": endTime},
            dataType: 'json',
            success: function (data) {
                console.log(data)

                chart.update({
                    title: {
                        text: data.title
                    },
                    yAxis: {
                        title: {
                            text: data.ytext
                        }
                    },
                    series: [{
                        name: data.seriesName,
                        colorByPoint: true,
                        data: data.seriesData
                    }]
                })
            },
            error: function (data) {
                console.log("错误")
                layer.alert('发生错误!', {icon: 2, time: 1000});
            },
        })
    })


</script>
</body>
</html>